package com.t235.gc.order.service;

import com.t235.gc.entity.HomeRecyclingOrder;
import com.t235.gc.mapper.HomeRecyclingDetailOrderMapper;
import com.t235.gc.mapper.HomeRecyclingOrderMapper;
import com.t235.gc.vo.HomeRecyclingOrderVo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
public class HomeRecyclingOrderService {
    @Resource
    private HomeRecyclingOrderMapper homeRecyclingOrderMapper;
    @Resource
    private HomeRecyclingDetailOrderMapper homeRecyclingDetailOrderMapper;
    public List<HomeRecyclingOrder> getList(HomeRecyclingOrderVo vo){
        return homeRecyclingOrderMapper.getList(vo);
    }
    public int getCount(HomeRecyclingOrderVo vo){
        return homeRecyclingOrderMapper.getCount(vo);
    }
    @Transactional
    public Integer del(String orderId){
        if(homeRecyclingDetailOrderMapper.deleteByOrderId(Long.parseLong(orderId))>0){
            if(homeRecyclingOrderMapper.deleteByPrimaryKey(Long.parseLong(orderId))>0){
                return 1;
            }
        }
        return -1;
    }
    public List<HomeRecyclingOrder> getListByOrderId(String orderId){
        return homeRecyclingOrderMapper.getListByOrderId(orderId);
    }
}
